package com.example.order.config;

public class ServiceResponse<T> {
    private Integer status;

    private T data;

    private String msg;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public ServiceResponse(Integer status) {
        this.status = status;
    }

    public ServiceResponse() {
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public ServiceResponse(Integer status, T data) {
        this.status = status;
        this.data = data;
    }

    public static ServiceResponse createSuccess() {
        return new ServiceResponse(0);
    }
    public static ServiceResponse createSuccess(String msg) {
        return new ServiceResponse(0,msg);
    }
    public static ServiceResponse createError(String msg) {
        return new ServiceResponse(-200,msg);
    }
    public static ServiceResponse createError(Integer status, String msg) {
        return new ServiceResponse(status,msg);
    }
    public static ServiceResponse createError() {
        return new ServiceResponse(1);
    }

    public static <T> ServiceResponse createSuccess(T data) {
        return new ServiceResponse(0,data);
    }

}
